<template>
  <div>
    <!-- 获取IP 地址插件 -->
  </div>
</template>
<script>
export default {
  mounted() {
    this.anLoad();
  },
  methods: {
    anLoad() {
      const script1 = document.createElement("script"); // 创建script标签节点
      script1.setAttribute("type", "text/javascript"); // 设置script类型
      script1.setAttribute("src", "http://pv.sohu.com/cityjson?ie=utf-8"); // 设置js地址
      document.body.appendChild(script1); // 将js追加为body的子标签

      // 判断script1是否加载成功
      script1.onload = script1.onreadystatechange = () => {
        if (
          !this.readyState ||
          this.readyState === "loaded" ||
          this.readyState === "complete"
        ) {
          // eslint-disable-next-line no-undef
          this.$emit("call-back", returnCitySN);
        }
      };
    },
  },
};
</script>
